//
//  ShareResouceDetailTableViewCell.m
//  ShangHaiHuDongApp
//
//  Created by 刘应平 on 2017/6/22.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "ShareResouceDetailTableViewCell.h"

@interface ShareResouceDetailTableViewCell ()
/**  titile  */
@property (strong, nonatomic) UILabel  *titleLabel;
/**  内容  */
@property (strong, nonatomic) UILabel  *content;
@end
@implementation ShareResouceDetailTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


/**  50  */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.titleLabel = [UILabel new];
        self.titleLabel.textAlignment = NSTextAlignmentLeft;
        self.titleLabel.textColor = [UIColor textBlackColor];
        self.titleLabel.font = LYPFONT(16);
        [self addSubview:self.titleLabel];
        self.titleLabel.sd_layout
        .topSpaceToView(self, 15 * [UIScreen zj_screenHScale])
        .leftSpaceToView(self, 20 * [UIScreen zj_screenWScale])
        .heightIs(20 * [UIScreen zj_screenHScale])
        .widthIs([UIScreen zj_screenWith] - 100 * [UIScreen zj_screenWScale]);
        
        self.content = [UILabel new];
        self.content.textAlignment = NSTextAlignmentRight;
        self.content.textColor = [UIColor textGrayColor];
        self.content.font = LYPFONT(15);
        self.content.numberOfLines = 0;
        [self addSubview:self.content];
        self.content.sd_layout
        .topSpaceToView(self, 15 * [UIScreen zj_screenHScale])
        .rightSpaceToView(self, 15 * [UIScreen zj_screenWScale])
        .heightIs(20 * [UIScreen zj_screenHScale])
        .widthIs([UIScreen zj_screenWith] - 100 * [UIScreen zj_screenWScale]);

        UIView *under = [UIView new];
        under.backgroundColor = [UIColor themeGrayColor];
        [self addSubview:under];
        under.sd_layout.leftEqualToView(self).bottomEqualToView(self).widthIs([UIScreen zj_screenWith]).heightIs(1);
    }
    return self;
}

- (void)setModel:(ShareResouceDetailModel *)model{
    _model = model;

    self.titleLabel.text = model.title;
    self.titleLabel.sd_layout.widthIs(model.titleWidth);
    [self.titleLabel updateLayout];
    
    self.content.text = model.content;
    self.content.sd_layout.widthIs([UIScreen zj_screenWith] - 45 * [UIScreen zj_screenWScale] - model.titleWidth).heightIs(model.contentHeight);
    [self.content updateLayout];
}


- (void)setRow:(NSInteger)row{
    _row = row;
    if (row == 0) {
        UIView *ten = [UIView new];
        ten.backgroundColor = [UIColor themeGrayColor];
        [self addSubview:ten];
        ten.sd_layout.leftEqualToView(self).bottomEqualToView(self).widthIs([UIScreen zj_screenWith]).heightIs(8 * [UIScreen zj_screenHScale]);
    }
}
@end
